<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:calli="http://callimachusproject.org/rdf/2009/framework#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:foaf="http://xmlns.com/foaf/0.1/">
<head>
    <title resource="?this">{rdfs:label}</title>
    <link rel="help" href="../../callimachus-for-web-developers#User_Profile" target="_blank" title="Help" />
    <script type="text/javascript">//<![CDATA[
        $(document).ready(function() {
            var uri = $("form[resource]").attr("resource");
            var credential = null;
            jQuery.ajax({type: "GET",  url: "/?profile",
                xhrFields: calli.withCredentials,
                success: function(doc) {
                    credential = /resource="([^" >]*)"/i.exec(doc)[1];
                }
            });
            var deleted = false;
            $(document).bind("calliDelete", function(event) {
                if (credential && credential == uri) {
                    deleted = true;
                }
                return true;
            });
            $(document).bind("calliRedirect", function(event) {
                if (deleted && credential && credential == uri) {
                    // need to log user out gracefully since they deleted themselves
                    var e = jQuery.Event("calliLogout");
                    e.location = '/';
                    $(document).trigger(e);
                    event.preventDefault();
                    return false;
                }
                return true;
            });
        });
        // ]]>
    </script>
</head>
<body resource="?this">
    <h1 property="rdfs:label" />
    <div id="sidebar">
        <aside>
            <p>Enter your full name</p>
            <p>Upload a small photo of yourself so others can recognize you using the photo icon</p>
            <p>Additional information is to provide additional contact information and is viewable to all authenticated users</p>
            <p>To change your password or email, click on the View tab, then select "Change password or email" from the main menu</p>
        </aside>
    </div>
    <form role="form" id="form" method="POST" action="" enctype="application/sparql-update" resource="?this" autocomplete="off">
        <fieldset>
            <div class="form-group">
                <label for="label">Full name</label>
                <div class="controls">
                    <input id="label" value="{rdfs:label}" type="text" class="form-control" required="required" />
                </div>
             </div>
             <div id="photo" dropzone="link s:text/uri-list" class="form-group" ondrop="return calli.insertResource(event)">
                <label>Photo <a href="../types/Photo?create" title="Upload"
                        onclick="return calli.createResource(event)" class="glyphicon glyphicon-list-alt" /></label>
                <div rel="foaf:depiction" class="controls">
                    <span resource="?img" typeof="foaf:Image" class="ui-state-highlight ui-corner-all">
                        <img src="{?img}?small" />
                    </span>
                </div>
            </div>
            <div class="form-group">
                <label for="comment">Additional information</label>
                <div class="controls">
                    <textarea id="comment" class="form-control">{rdfs:comment}</textarea>
                </div>
            </div>
            <div class="form-group">
                <button id="save" type="submit" class="btn btn-primary">Save</button>
                <button id="cancel" type="button" onclick="window.location.replace('?view')" class="btn btn-default">Cancel</button>
                <button id="delete" type="button" onclick="calli.deleteResource(event)" class="btn btn-danger">Delete</button>
            </div>
        </fieldset>
    </form>
</body>
</html>
